import { Model } from 'pinia-orm';
import { Attr, Str, Uid, Num, Bool, HasOne, HasMany, BelongsTo, HasManyBy, BelongsToMany, MorphOne,
  MorphTo, MorphMany, MorphToMany, OnDelete
  } from 'pinia-orm/decorators';
import { useAxiosRepo } from '@pinia-orm/axios';
import { useAppConfig } from '@vben/hooks';
import type { WechatopenApplet, WechatopenAppletResponse } from '../../views/uctoo/wechatopen_applet/types.js';
//#region Human-Code Preservation

//#endregion Human-Code Preservation

const { apiURL } = useAppConfig(import.meta.env, import.meta.env.PROD);

export class uctoo_wechatopen_applet extends Model {
  static override entity = 'uctoo_wechatopen_applet'

@Uid() declare id: string 
@Str('') declare name: string | null
@Str('') declare typedata: string | null
@Str('') declare token: string | null
@Str('') declare appid: string 
@Str('') declare appsecret: string | null
@Str('') declare aeskey: string | null
@Str('') declare mchid: string | null
@Str('') declare mchkey: string | null
@Str('') declare mch_api_cert: string | null
@Str('') declare mch_api_key: string | null
@Str('') declare notify_url: string | null
@Str('') declare principal: string | null
@Str('') declare original: string | null
@Str('') declare wechat: string | null
@Str('') declare headface_image: string | null
@Str('') declare qrcode_image: string | null
@Str('') declare signature: string | null
@Num(0) declare status: number 
@Num(0) declare weigh: number 
@Str('') declare service_type_info: string | null
@Str('') declare verify_type_info: string | null
@Str('') declare business_info: string | null
@Str('') declare authorizer_access_token: string | null
@Attr('') declare access_token_overtime: string | null
@Str('') declare authorizer_refresh_token: string | null
@Str('') declare miniprograminfo: string | null
@Str('') declare ticket: string | null
@Str('') declare ticket_overtime: string | null
@Uid() declare creator: string | null
@Attr('') declare created_at: string 
@Attr('') declare updated_at: string 
@Attr('') declare deleted_at: string | null
@Str('') declare func_info: string | null
@Str('') declare basic_config: string | null
@Num(0) declare channels_info: number | null
@Num(0) declare register_type: number | null
@Str('') declare redirect_url: string | null


  static override config = {
    axiosApi: {
        actions: {
            getuctooWechatopenAppletList(page: number, pageSize: number, searchParams?: any){
                return useAxiosRepo(uctoo_wechatopen_applet).api().get(`/uctoo/wechatopen_applet/${pageSize}/${page}`, {
                  params: searchParams,
                  headers: { 'Content-Type': 'application/json;charset=utf-8',
                          'Authorization': `Bearer ${localStorage.getItem('accessToken')}` 
                  },
                  baseURL: apiURL,
                  dataKey: 'wechatopenApplets'
                })
            },
            getuctooWechatopenApplet(id: string){
              return useAxiosRepo(uctoo_wechatopen_applet).api().get(`/uctoo/wechatopen_applet/${id}`, {
                headers: { 'Content-Type': 'application/json;charset=utf-8',
                        'Authorization': `Bearer ${localStorage.getItem('accessToken')}` 
                },
                baseURL: apiURL,
              })
            },
            adductooWechatopenApplet(data: Partial<WechatopenApplet>){
              return useAxiosRepo(uctoo_wechatopen_applet).api().post('/uctoo/wechatopen_applet/add', data, {
                headers: { 'Content-Type': 'application/json;charset=utf-8',
                        'Authorization': `Bearer ${localStorage.getItem('accessToken')}` 
                },
                baseURL: apiURL,
              })
            },
            edituctooWechatopenApplet(data: any){
              return useAxiosRepo(uctoo_wechatopen_applet).api().post('/uctoo/wechatopen_applet/edit', data, {
                headers: { 'Content-Type': 'application/json;charset=utf-8',
                        'Authorization': `Bearer ${localStorage.getItem('accessToken')}` 
                },
                baseURL: apiURL,
              })
            },
            deleteuctooWechatopenApplet(data: any){
              return useAxiosRepo(uctoo_wechatopen_applet).api().post('/uctoo/wechatopen_applet/del', data, {
                headers: { 'Content-Type': 'application/json;charset=utf-8',
                        'Authorization': `Bearer ${localStorage.getItem('accessToken')}` 
                },
                baseURL: apiURL,
              })
            },

//#region Human-Code Preservation

//#endregion Human-Code Preservation
        } 
    }
  }
}
